USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0003_VALORES_SEGUROS]    Script Date: 11/28/2011 12:07:52 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[WASP_M0003_VALORES_SEGUROS]') AND type in (N'P', N'PC'))
DROP PROCEDURE [dbo].[WASP_M0003_VALORES_SEGUROS]
GO

USE [BMIG_Mensual_POST_CADENA]
GO

/****** Object:  StoredProcedure [dbo].[WASP_M0003_VALORES_SEGUROS]    Script Date: 11/28/2011 12:07:52 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE PROCEDURE [dbo].[WASP_M0003_VALORES_SEGUROS]
AS

BEGIN
	SELECT	 a.ppsuc, a.ppcta, a.ppoper,
			 a.ppimp11, a.ppimp12, a.ppimp13, 
			 a.ppimp14, a.ppimp15, a.ppimp16,
			 a.ppimp17, a.ppimp18, a.ppimp19
			 
	INTO 
			 dbo.prima_comision_valores_seguros
			 
	FROM	 fsd611 as a (nolock),
			 fsd601 as b (nolock)
			 
	WHERE	 a.pptipo = '' and 
			 a.ppexte = 0  and
			 a.pgcod = b.pgcod and
			 a.ppmod = b.ppmod and
			 a.ppsuc = b.ppsuc and 
			 a.ppmda = b.ppmda and
			 a.ppcta = b.ppcta and 
			 a.ppoper = b.ppoper and
			 a.ppsbop = b.ppsbop and
			 a.pptope = b.pptope and
			 a.ppsbop = 0 and 
			 b.d601co = 'S'
			 
	GROUP BY a.ppsuc, a.ppcta, a.ppoper, a.ppimp11, a.ppimp12,
			 a.ppimp13, a.ppimp14, a.ppimp15, a.ppimp16,
			 a.ppimp17, a.ppimp18, a.ppimp19

END

GO

